#!/bin/env python3
# -*- encoding=utf-8 -*-
"""
# ********************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
# [openeuler-jenkins] is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You may obtain a copy of Mulan PSL v1 at:
#     http://license.coscl.org.cn/MulanPSL
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v1 for more details.
# Author: wangge
# Create: 2021-10-29
# ********************************************************************
"""

import os

# sbom top dir
OECT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
OECT_OUTPUT_PATH = os.path.join(OECT_DIR, "result")

# OBS 实时日志链接
OBS_PROJECT_LIVE_LOG= "https://build.openeuler.openatom.cn/build/{obs_project}/standard_{arch}/{arch}/{package_repo}/_log"
# OBS backup log
OBS_BACKUP_LOG = "http://117.78.1.88:82/obs_build_log/{obs_project}/{arch}/{package}"
# OBS 账号
ACCOUNT = "senlin"

OBS_HOST = "https://build.openeuler.openatom.cn/"
# openeuler dailybuild
EBS_DAILYBUILD_URL = "http://121.36.84.172/dailybuild/EBS-{branch}/{repo_dir}/Packages"
OBS_DAILYBUILD_URL = "http://121.36.84.172/dailybuild/{branch}/{repo_dir}/Packages"
OPENEULER_REPO_URL = 'https://repo.huaweicloud.com/openeuler/{repo_dir}/Packages'

SIGS_YAML_URL = 'https://gitee.com/openeuler/community/raw/master/sig/sigs.yaml'
SIG_OWNER_URL = 'https://gitee.com/openeuler/community/raw/master/sig/{signame}/OWNERS'
SPEC_URL = 'https://gitee.com/src-openeuler/{package}/raw/{branch}/{specfile}'


# openeuler branch bind with obs project
GITEE_BRANCH_PROJECT_MAPPING = {
    "master": ["openEuler:BaseTools", "openEuler:C", "openEuler:Common_Languages_Dependent_Tools",
                "openEuler:Erlang", "openEuler:Golang", "openEuler:Java", "openEuler:KernelSpace",
                "openEuler:Lua", "openEuler:Meson", "openEuler:MultiLanguage", "openEuler:Nodejs",
                "openEuler:Ocaml", "openEuler:Perl", "openEuler:Python", "openEuler:Qt",
                "openEuler:Ruby", "openEuler:Mainline", "openEuler:Epol"],
    "openEuler-20.03-LTS-SP1": ["openEuler:20.03:LTS:SP1", "openEuler:20.03:LTS:SP1:Epol"],
    "openEuler-20.03-LTS-SP3": ["openEuler:20.03:LTS:SP3", "openEuler:20.03:LTS:SP3:Epol"],
    "openEuler-22.03-LTS-Next": ["openEuler:22.03:LTS:Next", \
                                "openEuler:22.03:LTS:Next:Epol", \
                                "openEuler:22.03:LTS:Next:Epol:Multi-Version:OpenStack:Train", \
                                "openEuler:22.03:LTS:Next:Epol:Multi-Version:OpenStack:Wallaby"],
    "openEuler-22.03-LTS-SP1": ["openEuler:22.03:LTS:SP1", \
                                "openEuler:22.03:LTS:SP1:Epol", \
                                "openEuler:22.03:LTS:SP1:Epol:Multi-Version:OpenStack:Train", \
                                "openEuler:22.03:LTS:SP1:Epol:Multi-Version:OpenStack:Wallaby"],
    "openEuler-22.03-LTS": ["openEuler:22.03:LTS", "openEuler:22.03:LTS:Epol"],
    "openEuler-22.09": ["openEuler:22.09", "openEuler:22.09:Epol"]
}

EBS_OE_BRANCHES = ['openEuler-22.03-LTS-SP1', 
                          'openEuler-23.03', 
                          'openEuler-22.03-LTS-SP2',
                          'openEuler-23.09']

OE_PUBLISHED_HOST = 'https://repo.huaweicloud.com/openeuler/'

OE_PUBLISHED_REPO_DIRS = ['OS', 'everything', 'epol', \
                        'OpenStack_Tarin', 'OpenStack_Wallaby', \
                        'ROS_humble', 'everything_update', 'epol_update', \
                        'everything_src']

OE_PUBLISHED_REPO_MAPPING = {
    "openEuler-22.03-LTS-SP2":{
        'dist': 'oe2203sp2',
        'OS': 'openEuler-22.03-LTS-SP2/OS/{arch}',
        'everything': 'openEuler-22.03-LTS-SP2/everything/{arch}',
        'epol': 'openEuler-22.03-LTS-SP2/EPOL/main/{arch}',
        'OpenStack_Tarin': 'openEuler-22.03-LTS-SP2/EPOL/multi_version/OpenStack/Train/{arch}',
        'OpenStack_Wallaby': 'openEuler-22.03-LTS-SP2/EPOL/multi_version/OpenStack/Wallaby/{arch}',
        'ROS_humble': 'openEuler-22.03-LTS-SP2/EPOL/multi_version/ROS/humble/{arch}',
        'everything_update': 'openEuler-22.03-LTS-SP2/update/{arch}',
        'epol_update': 'openEuler-22.03-LTS-SP2/EPOL/update/main/{arch}',
        'everything_src': 'openEuler-22.03-LTS-SP2/{arch}'
    },
    "openEuler-22.03-LTS-SP1":{
        'dist': 'oe2203sp1',
        'OS': 'openEuler-22.03-LTS-SP1/OS/{arch}',
        'everything': 'openEuler-22.03-LTS-SP1/everything/{arch}',
        'epol': 'openEuler-22.03-LTS-SP1/EPOL/main/{arch}',
        'OpenStack_Tarin': 'openEuler-22.03-LTS-SP1/EPOL/multi_version/OpenStack/Train/{arch}',
        'OpenStack_Wallaby': 'openEuler-22.03-LTS-SP1/EPOL/multi_version/OpenStack/Wallaby/{arch}',
        'everything_update': 'openEuler-22.03-LTS-SP1/update/{arch}',
        'epol_update': 'openEuler-22.03-LTS-SP1/EPOL/update/main/{arch}',
    },
    "openEuler-23.09":{
        'dist': 'oe2309',
        'OS': 'openEuler-23.09/OS/{arch}',
        'everything': 'openEuler-23.09/everything/{arch}',
        'epol': 'openEuler-23.09/EPOL/main/{arch}',
        'ROS_humble': 'openEuler-23.09/EPOL/multi_version/ROS/humble/{arch}',
        'everything_update': 'openEuler-23.09/update/{arch}',
        'epol_update': 'openEuler-23.09/EPOL/update/main/{arch}',
        'everything_src': 'openEuler-23.09/{arch}'
    },
    "openEuler-23.03":{
        'dist': 'oe2303',
        'OS': 'openEuler-23.03/OS/{arch}',
        'everything': 'openEuler-23.03/everything/{arch}',
        'epol': 'openEuler-23.03/EPOL/main/{arch}',
        'everything_update': 'openEuler-23.03/update/{arch}',
        'epol_update': 'openEuler-23.03/EPOL/update/main/{arch}',
        'everything_src': 'openEuler-23.03/{arch}'
    },
}
OE_DAILYBUILD_REPO_MAPPING = {
    "openEuler-22.03-LTS-SP2":{
        'dist': 'oe2203sp2',
        'OS': '/OS/{arch}',
        'everything': '/everything/{arch}',
        'epol': '/epol/main/{arch}',
        'OpenStack_Tarin': '/EPOL/multi_version/OpenStack/Train/{arch}',
        'OpenStack_Wallaby': '/EPOL/multi_version/OpenStack/Wallaby/{arch}',
        'ROS_humble': '/EPOL/multi_version/ROS/humble/{arch}',
        'everything_update': '/update/{arch}',
        'epol_update': '/EPOL/update/main/{arch}',
        'everything_src': '/{arch}',
        'epol_main_src': '/epol/main/{arch}',
        'epol_multi_ros_src': '/EPOL/multi_version/ROS/humble/{arch}',
    },
    "openEuler-23.09":{
        'dist': 'oe2309',
        'OS': '/OS/{arch}',
        'everything': '/everything/{arch}',
        'epol': '/EPOL/main/{arch}',
        'ROS_humble': '/EPOL/multi_version/ROS/humble/{arch}',
        'everything_update': '/update/{arch}',
        'epol_update': '/EPOL/update/main/{arch}',
        'everything_src': '/{arch}',
    },
}


BUILD_REQUIRE_PATTERN = {
    'C': {
        'build_require': {'gcc', 'gcc-c++', 'glibc', 'glibc-common', 'make', 'automake', 'cmake'},
        'build_command': {'make_build', 'make', 'make ', '%{__make}'}
    },
    'python': {
        'build_require': {
            'python2', 'python-devel', 'python3', 'python2-devel', 
            'python3-devel', '/usr/bin/pathfix.py', '%{python}',
            'python3-pandas', 'python3-numpy', 'python3-pyelftools',
            '%{required_python}', '%{_py}'
            },
        'build_command': {'py3_build', 'py2_build', '%{__python3}'}
    },
    'java': {
        'build_require': {
            'maven-local', 'mvn', 'ant', 'maven', 
            'javapackages-local', 'gradle-local'
            },
        'build_command': {
            'mvn_build', 'mvn ', 'mvn_artifact ', 'gradle ', 
            'gradlew ', 'gradle-local', 'gradle_build', 'ant '
            }
    },
    'go': {
        'build_require': {
            'go', 'golang', 'golang-bin', 
            'compiler(go-compiler)', 
            'go-compilers-golang-compiler'
            },
        'build_command': {'go build', 'gobuild '}
    },
    'erlang': {
        'build_require': {'erlang', 'erlang-crypto'},
        'build_command': {'erlang_compile'}
    },
    'nodejs': {
        'build_require': {'nodejs', 'nodejs-packaging', 'nodejs-devel'},
        'build_command': {'nodejs_symlink_deps'}
    },
    'perl': {
        'build_require': {
            'perl-devel', 'perl-generators', 
            'perl-interpreter', 'perl'
            },
        'build_command': {'perl'}
    },
    'qt': {
        'build_require': {
            'qt4-devel', 'qt5-qtbase-devel', 
            'qt5-qtwebkit-devel', 'qt5-rpm-macros'
            },
        'build_command': {'qmake_qt4', 'qmake_qt5', 'qmake-qt5'}
    },
    'lua': {
        'build_require': {'lua-devel', 'lua'},
        'build_command': {'LUA_'}
    },
    'ruby': {
        'build_require': {
            'ruby', 'ruby-devel', 'rubygems-devel', 
            '%{?scl_prefix_ruby}ruby(release)', 
            '%{?scl_prefix_ruby}rubygems'
            },
        'build_command': {'rake', 'gem build'}
    },
    'rust': {
        'build_require': {'rust-packaging'},
        'build_command': {'cargo_build'}
    },
    'meson': {
        'build_require': {'meson'},
        'build_command': {'meson_build', 'meson '}
    },
    'mingw': {
        'build_require': {
            'mingw32-gcc-c++', 'mingw64-gcc-c++', 
            'mingw32-filesystem', 'mingw64-filesystem', 
            'mingw32-gcc', 'mingw64-gcc'
            },
        'build_command': {'mingw', 'mingw_make  '}
    },
    'ocaml': {
        'build_require': {'ocaml'},
        'build_command': {'jbuilder '}
    },
    'php': {
        'build_require': {'php-devel'},
        'build_command': {}
    }
}

